const UserKey = 'UserKey'
const TokenKey = 'TokenKey'

// token 数据保存在 sessionStorage
export function getTokenLocal() {
	return sessionStorage.getItem(TokenKey)
}

export function setTokenLocal(token) {
	return sessionStorage.setItem(TokenKey, token)
}

export function removeTokenLocal() {
	return sessionStorage.removeItem(TokenKey)
}

// 用户信息保存在本地存储 localStorage 
export function getUserLocal() {
	let user = localStorage.getItem(UserKey)
	return user ? JSON.parse(user) : {}
}

export function setUserLocal(user) {
	return localStorage.setItem(UserKey, JSON.stringify(user))
}

export function removeUserLocal() {
	return localStorage.removeItem(UserKey)
}